<?php

$root =  dirname(dirname(dirname(__FILE__)));
//var_dump($root);
$config = require_once($root . '/src/config/config.php');

$conn = mysql_connect($config['db_config']['host'], $config['db_config']['user'], $config['db_config']['pass']) or die("connect failed" . mysql_error());
mysql_set_charset($config['db_config']['charset'],$conn);
mysql_select_db($config['db_config']['database'], $conn);

$var = '上海';
$sql = 'select phone_number,location from '.$config['db_config']['tablename'].' where location like "'.$var.'%" order by phone_number limit 1';

//echo $sql;
$result = mysql_query($sql, $conn);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    var_dump($row['location']);
    $ret = str_replace('上海', '', $row['location']);
    var_dump($ret);
    $row['location'] = str_replace($ret, '  ', $row['location']);
    var_dump($row['location']);
}